package cn.edu.neu.lab603.math

import breeze.linalg.DenseMatrix

/** Helper methods to construct a network.
  *
  * Created by yfwz100 on 2016/11/30.
  */
object NetworkHelper {

  def network(n: Int): DenseMatrix[Double] = DenseMatrix.zeros[Double](n, n)

  implicit class Network(val network: DenseMatrix[Double]) extends AnyVal {
    def addEdge(edge: (Int, Int)): Unit = addEdge(edge._1, edge._2)

    def addEdge(rows: Int, cols: Int): Unit = {
      network.update(rows, cols, 1)
      network.update(cols, rows, 1)
    }
  }

  implicit class RichInt(val i: Int) extends AnyVal {
    def <->(j: Int): (Int, Int) = (i, j)
  }

}
